//
//  GCDQueue.h
//  MyFunctionDemo
//
//  Created by Ting Han on 2017/8/28.
//  Copyright © 2017年 Ting Han. All rights reserved.
//

#import <Foundation/Foundation.h>

@class GCDGroup;
@class GCDSemaphore;
@interface GCDQueue : NSObject

@property (nonatomic,strong,readonly) dispatch_queue_t dispatchQueue;

//获取线程
+ (instancetype)mainQueue;
+ (instancetype)lowPriorityGlobalQueue;
+ (instancetype)highPriorityGlobalQueue;
+ (instancetype)globalQueue;
+ (instancetype)backgroundPriorityGlobalQueue;
//初始化线程
- (instancetype)init;
- (instancetype)initSerial;
- (instancetype)initSerialWithIdentifier: (NSString *)identifier;
- (instancetype)initConcurrent;
- (instancetype)initConcurrentWithIdentifier: (NSString *)identifier;

//便利方法
+ (void)executeInMainQueue:(dispatch_block_t)block;
+ (void)executeInGlobalQueue:(dispatch_block_t)block;
+ (void)executeInHighPriorityGlobalQueue:(dispatch_block_t)block;
+ (void)executeInLowPriorityGlobalQueue:(dispatch_block_t)block;
+ (void)executeInBackgroundPriorityGlobalQueue:(dispatch_block_t)block;
+ (void)executeInMainQueue:(dispatch_block_t)block afterDelaySecs:(NSTimeInterval)sec;
+ (void)executeInGlobalQueue:(dispatch_block_t)block afterDelaySecs:(NSTimeInterval)sec;
+ (void)executeInHighPriorityGlobalQueue:(dispatch_block_t)block afterDelaySecs:(NSTimeInterval)sec;
+ (void)executeInLowPriorityGlobalQueue:(dispatch_block_t)block afterDelaySecs:(NSTimeInterval)sec;
+ (void)executeInBackgroundPriorityGlobalQueue:(dispatch_block_t)block afterDelaySecs:(NSTimeInterval)sec;

//操作
- (void)execute: (dispatch_block_t)block;
- (void)execute: (dispatch_block_t)block delay: (NSTimeInterval)delay;
- (void)execute: (dispatch_block_t)block wait: (GCDSemaphore *)semaphore;
- (void)execute: (dispatch_block_t)block delay: (NSTimeInterval)delay wait: (GCDSemaphore *)semaphore;

- (void)resume;
- (void)suspend;
- (void)barrierExecute: (dispatch_block_t)block;


- (void)notify: (dispatch_block_t)block inGroup: (GCDGroup *)group;
- (void)execute: (dispatch_block_t)block inGroup: (GCDGroup *)group;




@end
